<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>11-遍历相关</title>
		<script type="text/javascript" src="js/jquery2.1.4.min.js"></script>
	</head>
	<body>
		<div>百度1</div>
		<div>百度2</div>
		<div>百度3</div>
		<script type="text/javascript">
			//$.each() 遍历数组、对象
			
			$(function(){
				//console.log('abc...');
				
				//遍历数组
				var arr = ['red','blue','orange'];
 				/*
					for(var i=0;i<arr.length;i++){
						console.log(arr[i]);
					}
				*/
			   //1.遍历数组
			   //$.each(arr,function(){});
/* 				$.each(arr,function(index,ele){
					console.log("索引:"+index);
					console.log("值:"+ele);
				}); */
				//2.遍历单个对象
/* 				var user = {
					username:'libaoli',
					password:'123456'
				};
				$.each(user,function(index,ele){
					console.log(index);//属性名
					console.log(ele);//属性值
				}); */
				
				//3.遍历元素对象
				console.log($('div'));
				//$.each($('div'),function(index,eleDom){});
				$.each($('div'),function(index,eleDom){
					console.log(index);//索引
					console.log(eleDom);//原生DOM
				});

			});
		</script>
	</body>
</html>
